home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
USA Bestseller
/
USA BESTSELLER Vol 1-95 (Hepp-Computer)(1995).iso
/
e190
/
video.asm
< prev
next >
Wrap
Assembly Source File
|
1995-02-20
|
5KB
|
223 lines
.286
;; Compact model
LOCALS
;; ----------------- UNINITIALIZED FAR DATA --------------------------
_FARBSS SEGMENT PARA PUBLIC 'FAR_BSS'
PUBLIC ram_buffer
ram_buffer DB 64016 DUP (?) ;; buffer for reading/writing to video
_FARBSS ENDS
;; --------------------------- CODE ----------------------------------
_TEXT SEGMENT PARA PUBLIC 'CODE'
PUBLIC _set_tweaked,_set_gmode,_fillbuf,_fillbuft
ASSUME CS:_TEXT
;; ------------------------------------------------------------------ ;;
;; extern "C" void set_tweaked();
;; ------------------------------------------------------------------
;; Setup tweaked mode 13h. (320x200x256 colors, with 4 pages)
;; Code taken from Michael Abrash's Power Graphics Programming.
;; ------------------------------------------------------------------ ;;
_set_tweaked PROC
push si di
mov ax,13h ;; Use BIOS to set to mode 13h (320x200x256 colors)
int 10h
;; Disable chain 4 mode
mov dx,03c4h ;; Sequencer Index
mov al,4 ;; memory mode register
out dx,al
inc dx
in al,dx
and al,not 08h ;; turn off chain 4
or al,04h ;; turn off odd/even
out dx,al
mov dx,03ceh ;; Graphics Controller Index
mov al,5 ;; graphics mode register
out dx,al
inc dx
in al,dx
and al,not 010h ;; turn off odd/even
out dx,al
dec dx
mov al,6 ;; miscellaneous register
out dx,al
inc dx
in al,dx
and al,not 02h ;; turn off chain
out dx,al
;; Change CRTC scanning from doubleword mode to byte mode,
;; allowing the CRTC to scan more than 64 K of video data
mov dx,03d4h ;; CRTC Index
mov al,014h ;; underline register
out dx,al
inc dx
in al,dx
and al,not 040h ;; turn off doubleword
out dx,al
dec dx
mov al,017h ;; mode control register
out dx,al
inc dx
in al,dx
or al,040h ;; turn off byte mode bit, so memory is scanned
;; for video data in a purely linear way, just
;; as in modes 010h and 012h
out dx,al
;; Clear the video memory, 8 pixels at a time
mov dx,03c4h ;; Sequencer Register Index
mov ax,0f02h
out dx,ax ;; Enable writes to all four planes
mov ax,0a000h
mov es,ax
sub di,di
sub ax,ax ;; Clear to 0
mov cx,8000h ;; # of words in display memory
rep stosw
pop di si
ret
_set_tweaked ENDP
;; ------------------------------------------------------------------ ;;
;; extern "C" void set_gmode(int gmode);
;; ------------------------------------------------------------------
;; Set graphics mode using BIOS
;; ------------------------------------------------------------------ ;;
_set_gmode PROC C
ARG gmode:WORD
;; Save registers BIOS modifies
push si
push di
mov ax,[gmode]
xor ah,ah ;; function:set video mode
int 10h
pop di
pop si
ret
_set_gmode ENDP
ASSUME ES:_FARBSS
;; ------------------------------------------------------------------ ;;
;; extern "C" void fillbuf();
;; ------------------------------------------------------------------
;; Pretend ram_buffer is set up in a non-planar form, and fill it
;; with random color patterns. For use by mode 13h benchmarks.
;; ------------------------------------------------------------------ ;;
_fillbuf PROC
push di
mov ax,_FARBSS
mov es,ax
mov di,OFFSET ram_buffer
mov ax,0101h ;; blue
mov cx,16000/2 ;; fill a quarter of screen (using WORDs)
rep stosw
mov ax,0404h ;; red
mov cx,16000/2 ;; next quarter
rep stosw
mov ax,0505h ;; magenta
mov cx,16000/2 ;; third quarter
rep stosw
mov ax,0202h ;; green
mov cx,16000/2 ;; last quarter
rep stosw
mov ax,0 ;; black
mov cx,16/2 ;; fill up remaining 'extra' with black
rep stosw
pop di
ret
_fillbuf ENDP
;; ------------------------------------------------------------------ ;;
;; extern "C" void fillbuft();
;; ------------------------------------------------------------------
;; Pretend ram_buffer is set up in a planar fashion, and fill it up
;; with random color patterns. For use by Tweaked mode benchmarks.
;; ------------------------------------------------------------------ ;;
_fillbuft PROC
push di
mov ax,_FARBSS
mov es,ax
mov di,OFFSET ram_buffer ;; start at plane 0, top quarter
mov bx,4 ;; plane count
mov ax,0202h ;; green
@@PlaneDraw1:
mov cx,4000/2 ;; one quarter
rep stosw
add di,12000 ;; next plane
dec bx
jnz @@PlaneDraw1
mov di,OFFSET ram_buffer+4000 ;; start at plane 0, 2nd quarter
mov bx,4
mov ax,0505h ;; magenta
@@PlaneDraw2:
mov cx,4000/2 ;; one quarter
rep stosw
add di,12000 ;; next plane
dec bx
jnz @@PlaneDraw2
mov di,OFFSET ram_buffer+8000 ;; start at plane 0, 3rd quarter
mov bx,4
mov ax,0404h ;; red
@@PlaneDraw3:
mov cx,4000/2 ;; one quarter
rep stosw
add di,12000 ;; next plane
dec bx
jnz @@PlaneDraw3
mov di,OFFSET ram_buffer+12000 ;; start at plane 0, 4th quarter
mov bx,4
mov ax,0101h ;; blue
@@PlaneDraw4:
mov cx,4000/2 ;; one quarter
rep stosw
add di,12000 ;; next plane
dec bx
jnz @@PlaneDraw4
pop di
ret
_fillbuft ENDP
_TEXT ENDS
END